package com.noyes4j.system.api.feign.factory;

import com.noyes4j.common.core.domain.R;
import com.noyes4j.system.api.feign.RemoteDeviceService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDeviceService>
{
    Logger log= LoggerFactory.getLogger(RemoteDeviceFallbackFactory.class);

    @Override
    public RemoteDeviceService create(Throwable throwable)
    {
        log.error(throwable.getMessage());
        return new RemoteDeviceService()
        {

            @Override
            public R getAirKissConfigData(String wifiSsid, String wifiPwd, String jsCode) {
                String msg = "getAirKissConfigData feign is error";
                log.error(msg);
                return R.error(msg);
            }

            @Override
            public void getAirKissQrCode(String path) {
                String msg = "getAirKissQrCode feign is error";
                log.error(msg);
            }

            @Override
            public R bindDeviceWithWechat(String sn, String openid) {
                String msg = "bindDeviceWithWechat feign is error";
                log.error(msg);
                return R.error(msg);
            }

            @Override
            public R getTest(String msg) {
                String vmsg = "getTest feign is error";
                log.error(vmsg);
                return R.error(vmsg);
            }

            @Override
            public R postTest(String msg) {
                String vmsg = "postTest feign is error";
                log.error(vmsg);
                return R.error(vmsg);
            }
        };
    }
}
